﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">
        function MoveTo(x,y) {
            document.getElementById("newX").value = x;
            document.getElementById("newY").value = y;

            document.forms[0].submit();
        }

        
        $(document).ready(function () {
            
        });
    </script>

    
    
    <div>
        <form method="get" id="form" name="form" action="<%=Html.ViewContext.HttpContext.Request.Path %>">

            <input id="newX" name="newX" type="hidden" />
            <input id="newY" name="newY" type="hidden" />

            <%if (ViewData["Player"] is PlayerModel)
            { 
                PlayerModel player = ViewData["Player"] as PlayerModel; 
                FieldModel playerField = player.getField(0,0); %>
                
                <div style="width:200px; float:left; height:400px; overflow:auto; margin-left:10px;">
                    <div>
                        <table cellpadding="0" cellspacing="0">
                            <tr>
                                <td>Name</td>
                                <td colspan="3"><%=player.Data.Name %></td>
                            </tr>
                            <tr>
                                <td colspan="4">Gesundheit</td>
                            </tr>
                            <tr>
                                <td colspan="4">
                                    <table width="100%">
                                        <tr>
                                            <td><%=player.Endurance %></td>
                                            <td>/</td>
                                            <td><%=player.Data.Endurance %></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4">Eigenschaften</td>
                            </tr>
                            <tr>
                                <td>Körperkraft</td>
                                <td><%=player.Strength %></td>
                                <td>/</td>
                                <td><%=player.Data.Strength %></td>
                            </tr>
                            <tr>
                                <td>Klugheit</td>
                                <td><%=player.Intelligence %></td>
                                <td>/</td>
                                <td><%=player.Data.Intelligence %></td>
                            </tr>
                            <tr>
                                <td>Geschicklichkeit</td>
                                <td><%=player.Dexterity %></td>
                                <td>/</td>
                                <td><%=player.Data.Dexterity %></td>
                            </tr>
                            <tr>
                                <td colspan="4">Widerstand gegen:</td>
                            </tr>
                            <tr>
                                <td>Waffen</td>
                                <td><%=player.PhysicalResistance %></td>
                                <td>/</td>
                                <td><%=player.Data.PhysicalResistance %></td>
                            </tr>
                            <tr>
                                <td>Magie</td>
                                <td><%=player.MagicalResistance %></td>
                                <td>/</td>
                                <td><%=player.Data.MagicalResistance %></td>
                            </tr>
                            <tr>
                                <td>Gift</td>
                                <td><%=player.PoisonResistance %></td>
                                <td>/</td>
                                <td><%=player.Data.PoisonResistance%></td>
                            </tr>
                            <tr>
                                <td>Feuer</td>
                                <td><%=player.FireResistance %></td>
                                <td>/</td>
                                <td><%=player.Data.FireResistance %></td>
                            </tr>
                            <tr>
                                <td>Wasser</td>
                                <td><%=player.WaterResistance %></td>
                                <td>/</td>
                                <td><%=player.Data.WaterResistance %></td>
                            </tr>
                        </table>
                    </div>
                </div>

                <div style="width:350px; float:left; height:400px; overflow:auto; margin-left:10px;">
                    <% for (int y = -3; y <= 3; y++)
                        {
                            for (int x = -3; x <= 3; x++)
                                {                                   
                                    FieldModel field = player.getField(x, y);
                                    if (field != null)
                                    {
                                        if (field.X == player.xPosition && field.Y == player.yPosition)
                                        {%>
                                            <div style="float:left; height:50px; width:50px; 
                                                cursor:help;
                                                background-image:url(../../Content/images/field_map/<%=field.Data.MapImageFilename %>);">
                                                <img src="../../Content/images/player.png" alt="Spieler" style="margin-top:5px; margin-left:5px;"/>
                                            </div>    
                                        <%}
                                        else if ((Math.Abs(field.X - player.xPosition) == 1 && Math.Abs(field.Y - player.yPosition) == 1) ||
                                                    (Math.Abs(field.X - player.xPosition) == 1 && field.Y == player.yPosition) ||
                                                    (Math.Abs(field.Y - player.yPosition) == 1 && field.X == player.xPosition))
                                        { %>
                                            <div onclick="MoveTo(<%=x %>,<%=y %>);"
                                                style="float:left; height:50px; width:50px; cursor:move;                                                 
                                                background-image:url(../../Content/images/field_map/<%=field.Data.MapImageFilename %>);" >
                                                <a style="color:Black; margin-left:40px;"><%=field.NumberOfCreatures %></a>
                                            </div>    
                                        <%} 
                                        else
                                        { %>
                                            <div style="float:left; height:50px; width:50px; cursor:crosshair;
                                                background-image:url(../../Content/images/field_map/<%=field.Data.MapImageFilename %>);" >
                                                <a style="color:Black; margin-left:40px;"><%=field.NumberOfCreatures %></a>
                                            </div>    
                                        <%} 
                                        } else { %>
                                        <div style="float:left; height:50px; width:50px; cursor:text;
                                            background-image:url(../../Content/images/field_map/out.png);">
                                        </div>
                                    <%} %>
                            <% }%>
                            <div style="clear:both;">
                            </div>                            
                        <% }%>
                        <div style="width:350px;">                        
                            Du befindest Dich bei den Koordinaten <%=player.xPosition %> : <%=player.yPosition %>
                        </div>
                        <div style="clear:both;">
                        </div>
                </div>

                <div style="width:300px; float:left; margin-left:10px; ">                              
                    <div style="width:300px;">
                        <div style="float:left; width:150px;">
                            <img src="../../Content/images/field_back/<%=playerField.Data.BigImageFilename %>" alt="<%=playerField.Data.Name %>"  style="padding:0px; margin:0px;"/>
                        </div>
                        <div style="float:left; width:150px;">
                            <div style="font-size:14px; font-weight:bold;">
                                <%=playerField.Data.Name%>
                            </div>
                            <div>
                                <%=playerField.Data.Description%>
                            </div>
                        </div>
                    </div>

                    <div style="clear:both;">
                    </div>                  

                    <div style="float:left; width:140px;">                  
                        <%if (player.PlayerField.Creatures != null) if(player.PlayerField.Creatures.Count()>0)
                        { %>
                            <div style="font-weight:bold;">
                                Hier begegnest Du
                            </div>

                            <div style="width:140px; height:260px; overflow:auto; ">
                                <%foreach (CreatureModel creature in player.PlayerField.Creatures)
                                  { %>
                                    <div style="width:120px; height:100px;
                                                margin-top:5px; 
                                                background-repeat:no-repeat;
                                                background-image:url(../../Content/images/creatures/<%=creature.Data.BigImageFilename %>);"
                                            onmouseover="ShowInfo('<%=creature.Data.Name%>', '<%=creature.Data.Description%>')" 
                                            onmouseout="HideInfo()">
                                        <div style="margin-left:2px; margin-right:2px; margin-top:2px; 
                                                    text-align:center; font-size:10px;
                                                    border-style:solid; border-color:White;                                                    
                                                    background-color:Green; color:White; border-width:thin;">
                                            Zustand: <%=creature.Data.Endurance %> %
                                        </div>
                                        <div style="margin-left:2px; margin-top:60px;">                                            
                                            <button id="attackButton" name="attackButton" value="<%= creature.ID %>" 
                                                    style="font-size:10px;">angreifen</button>
                                        </div>
                                    </div> 
                                <%} %>
                            </div>
                        <%} %>
                    </div>

                    <div style="float:left; width:140px; vertical-align:top;">                  
                        <%if (player.PlayerField.Items != null) if (player.PlayerField.Items.Count() > 0)
                        { %>
                            <div style="font-weight:bold;">
                                Du findest hier: 
                            </div>

                            <div style="width:140px; height:260px; overflow:auto; vertical-align:top;">
                                <%foreach (ItemModel item in player.PlayerField.Items)
                                  { %>
                                    <div style="width:120px; height:100px;
                                                margin-top:5px; 
                                                background-repeat:no-repeat;
                                                background-image:url(../../Content/images/items/<%=item.Data.Imgfilename %>);"
                                            onmouseover="ShowInfo('<%=item.Data.Name%>', '<%=item.Data.Description%>')" 
                                            onmouseout="HideInfo()">                                        
                                        <div style="margin-left:2px;">                                            
                                            <button id="takeButton" name="takeButton" value="<%= item.ID %>" 
                                                    style="font-size:10px;">nehmen</button>
                                        </div>
                                    </div> 
                                <%} %>
                            </div> 
                        <%}%>
                    </div>

                    <div style="clear:both;">
                    </div>                  
                </div>
            <% }%>
        </form>
    </div>
</asp:Content>
